package www.houdoudou.com.supplier;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import com.houdoudou.com.owner.OwnerManagement;

public class SupplierServlet extends HttpServlet {
	private static final long serialVersionUID = 3L;
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		   req.setCharacterEncoding("UTF-8"); 
		    resp.setCharacterEncoding("UTF-8");
		    PrintWriter print=resp.getWriter();  
		       
	        String jsonData=req.getParameter("jsonData");
	        String PostCode=req.getParameter("PostCode");
	        
	        int postCode=Integer.parseInt(PostCode);
	        System.out.println("there is requst in SupplierServlet"+PostCode+jsonData);
	        switch(postCode){
	        case 1:  {  //1验证管理员是否注册，成功 返回e参数，失败返回失败原因
	        	      JSONObject temp=  SupplierManagement.loginCheck(jsonData);
	    	          print.println( temp.toString()); 
	    	          System.out.println("data back to app----"+temp);
	    	          break;} 
          
			  case 2:  {  //管理目录
        	      JSONObject temp=  SupplierDoSth.manageIndex(jsonData);
    	          print.println( temp.toString()); 
    	          System.out.println("data back to app----"+temp);
    	          break;} 
			  case 3:  {  //管理产品
        	      JSONObject temp=  SupplierDoSth.manageProduct(jsonData);
    	          print.println( temp.toString()); 
    	          System.out.println("data back to app----"+temp);
    	          break;} 
        }
	        
	        print.close();  
	 }
	
}
